#ifndef __SERVER_H_
#define __SERVER_H_
#include<netinet/in.h>
#include<sys/types.h>


extern const char* program_name;

// if nonzero, print verbose message
extern int verbose;

extern void* xmalloc(size_t size);

extern void* xrealloc(void* ptr,size_t size);

extern char* xstrdup(const char* s);

extern void system_error(const char* operation);
extern void error(const char* cause,const char* msg);
extern char * get_self_executable_directory();



typedef void (* Fun) (int);
/* An instance of a loaded server module. */
struct server_module {
    /* The shared library handle corresponding to the loaded module. */
    void* handle;
    /* A name describing the module. */
    const char* name;

    /* The function that generates the HTML results for this module. */
    Fun generate_function;
};


extern struct server_module* module_open (const char* module_name);

extern void module_close (struct server_module* module);


extern void server_run (struct in_addr local_address, uint16_t port);
#endif